#ifndef PROTOCOL_H
#define PROTOCOL_H
#include <QObject>
#include <QtEndian>
#define MAX_QUEUE		        10
#define PORT                            8438

enum PACKETTYPE
{
    ADDVEH,         //增加车辆类型
    DELVEH,         //删除车辆类型
    MODVEH,         //修改车辆类型
    RESVEH,         //回应类型
    QUEVEH,          //队列类型
    HEADVEH
};

enum RESTYPE
{
    SUCCESS,        //成功
    FAIL            //失败
};
#pragma pack (push, 1)
//车型信息
typedef struct tagVehicle
{
    int nClass;					// vehicle class
    int nAxle;					// number of axle
    int nHeight;				// Height at first axle
    int bDualTyre;				// dual tyre on at least one axle
    __int64  tTransit;				// transit time (upto sec.)
    char    szAxleType[9];			// 轴型，如1125、1127等 V1.3
    int nAxleClass;				// 根据车型判断出来的车型 V1.5
    int nRaisedAxle;				// 是否有浮轴 V1.5
} VEHICLE;

//报文头
typedef struct
{
    quint8 nType;
    quint32 nLength;
public:
    void toBigEndian()
    {
        nLength = qFromBigEndian(nLength);
    }
} SHead;

//操作报文
typedef struct
{
    int nVehType;
    quint8 nXOR;
public:
    void toBigEndian()
    {
        nVehType = qFromBigEndian(nVehType);
    }
} SControlInfo;

//队列报文
typedef struct
{
    VEHICLE vehQueue[MAX_QUEUE];
    quint8 nXor;
} SVehInfo;
//队首报文
typedef struct
{
    VEHICLE headVeh;
    quint8 nXor;
} SHEADVEH;
//回应报文
typedef struct
{
    int nError;
    quint8 nXor;
public:
    void toBigEndian()
    {
        nError = qFromBigEndian(nError);
    }
} SResponse;
#pragma pack(pop)

#endif // PROTOCOL_H
